package coroutines.cancel

import kotlinx.coroutines.*

class WithTimeOutTest {
    companion object {
        suspend fun test() {
            var count = 0L
            while (true) {
                delay(100)
                println("test ${count++}")
            }
        }

        suspend fun noCancel() {
            withContext(NonCancellable) {
                var count = 0L
                while (true) {
                    delay(100)
                    println("test ${count++}")
                }
            }
        }
    }
}

fun main() {
    runBlocking {
        withTimeout(10000L) {
            WithTimeOutTest.test()
        }
    }
}